<?php if ($success!=''){?>
<h4 class="alert_success"><?php echo $success;?></h4>
<?php }?>
<?php if ($error!=''){?>
<h4 class="alert_error"><?php echo $error;?></h4>
<?php }?>

<article class="width_full module"> 
<header>
	<h3 class="tabs_involved">Danh sách công ty</h3>
	<script src="<?php echo base_url();?>/js/tabcontent.js" type="text/javascript"></script>
</header>
<form method="POST" action="<?php echo site_url();?>/internship/company" id="form-filter">
<div>
	<div>
		<?php if($type==1) { ?>
	    <ul class="tabs">
	    	<li><a href="#" rel="view1">Công ty</a></li>
	        <li><a href="#" rel="view2">Công ty đề xuất</a></li>
	    </ul>
	    <?php } ?>
    	<div class="tabcontents">
	      	<div class="tabcontent" id="view1">
		        <table class="tablesorter" cellspacing="0">
					<thead>
						<tr>
							<?php if($type==1) { ?>
								<th></th>
							<?php } ?>
							<th>STT</th>
							<th>Công ty</th>
							<th>Địa chỉ</th>
							<th>Email</th>
							<!-- <th>Mô tả</th> -->
							<th>Yêu cầu thực tập</th>
							<th>Số lượng thực tập</th>
							<th><center>Đã đăng ký</center></th>
						</tr>
						<tr style="background: none;cursor:default;display:none;" id="search-bar">
							<td></td>
							<td><input type="text" name="name" value="<?php echo @$filter['name'];?>"/></td>
							<td><input type="text" name="email" value="<?php echo @$filter['email'];?>"/></td>
							<td></td>
							<td></td>
							<!-- <td><input type="text" name="require" value="<?php echo @$filter['require'];?>" style="width:60px;"/></td> -->
							<td></td>
							<td></td>
							<td><a class="button-filter" onclick="$('#form-filter').submit();">Filter</a></td>
						</tr>
					</thead>
					<tbody>
						<?php 
							$i = 1;
							if (isset($companies)) foreach ($companies as $item){
							$tmp = explode('|',$item->email);
						?>
						<tr>
							<?php if($type==1) { ?>
								<td><input type="checkbox" name="company[]" value="<?php echo $item->id; ?>"></td>
							<?php } ?>
							<td><?php echo $i;?></td>
							<td><?php echo $item->name;?></td>
							<td><?php echo $item->address;?></td>
							<td><?php echo $tmp[0];?></td>
							<!-- <td><?php echo str_replace('\n',"<br/>\n",str_replace('\r\n',"<br/>\n",$item->description));?></td> -->
							<td><?php echo str_replace('\n',"<br/>\n",str_replace('\r\n',"<br/>\n",$item->requirement));?></td>
							<td><?php echo $item->traineeNum;?></td>
							<td><?php echo $item->regNum;?></td>
							<td></td>
						</tr>
						<?php $i++;?>
						<?php }?>
					</tbody>
				</table>
				<div>
					<?php echo $link; // tạo link phân trang  ?>
				</div>
	      	</div>
	      	<?php if($type == 1) {?>
	      	<div class="tabcontent" id="view2">
				<fieldset>
					<table>
						<thead>
							<tr>
								<td>
									<label>Tên công ty</label>
									<input type="text" name="company_other_name">
								</td>
							</tr>
							<tr>
								<td>
									<label>Address</label>
									<input type="text" name="company_other_email">
								</td>
							</tr>
							<tr>
								<td>
									<label>Email</label>
									<input type="text" name="company_other_address">
								</td>
							</tr>
						</thead>
					</table>
				</fieldset>
	      	</div>
	      	<?php } ?>
      	</div>
      	<?php if($type==1) { ?>
      		<input type="submit" value="Đăng ký thực tập">
      	<?php } ?>
    </div>
	<!-- end of #tab1 -->
</div><!-- end of .tab_container --> 
</form>
</article><!-- end of content manager article -->

<script type="text/javascript">
	$(document).ready(function(){ 
		$(".tablesorter").tablesorter({headers: {8:{sorter:false}} }); 
	});
</script>
